home *** CD-ROM | disk | FTP | other *** search
- Path: dawn.mmm.com!news
- From: kjhopps@mmm.com (Kevin J Hopps)
- Newsgroups: comp.lang.c++
- Subject: Re: Will it be auto-deleted?
- Date: 21 Feb 1996 18:02:14 GMT
- Organization: 3M - St. Paul, MN 55144-1000 US
- Message-ID: <4gfmn6$bsl@dawn.mmm.com>
- References: <1996Feb20.110314.46035@yogi.urz.unibas.ch>
- Reply-To: kjhopps@mmm.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Song Jin (song@iso.iso.unibas.ch) wrote:
- > I have a question:
-
- > void myfunction(void)
- > {
- > double *mypointer = new double[100];
-
- > .....
-
- > }
-
- > The mypointer and the buffer it pointed will be auto-deleted after returned
- > from myfunction, am I right?
-
- No, as others have said. If you want an array of double to live for the
- duration of myfunction(), and you know the dimension ahead of time, use
- automatic storage:
- void myfunction()
- {
- double myarray[100];
- ...
- }
- --
- Kevin J. Hopps e-mail: kjhopps@mmm.com
- 3M Company phone: (612) 737-4643
- 3M Center, Bldg. 235-2D-57 fax: (612) 737-2700
- St. Paul, MN 55144-1000 Opinions are my own. I don't speak for 3M.
- But 3M speaks for me -- I did not write the following line:
-
- Opinions expressed herein are my own and may not represent those of 3M.
-